<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="lg"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="lg2"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/font.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/xadmin.css">
<script type="text/javascript"
	src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/lib/layui/layui.js"
	charset="utf-8">
	
</script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/js/xadmin.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/static/js/cookie.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
	<div class="x-nav">
		<a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			href="javascript:location.replace(location.href);" title="刷新"> 刷新</a>
	</div>
	<!-- 查询条件 -->
	<div class="x-body">
		<div class="layui-row">
			<form class="layui-form layui-col-md12 x-so" action="${pageContext.request.contextPath}/contracts/list"
		method="post"> 
				<div class="layui-input-inline">
					<select name="serch_id" lay-verify=""
						style="width: 150px; position: right">
						<option value="">请选择员工查询</option>
						<lg:forEach items="${staffList}" var="sta" >
							<option value="${sta.id}"
							<lg:if test="${sta.id==staff.id}">
							${selected="selected"}
							</lg:if>>${sta.staff_name}
					
						</option>
						</lg:forEach>
					</select>
				</div>
				<button class="layui-btn" lay-submit="" lay-filter="sreach">
					<i class="layui-icon">&#xe615;</i>
				</button>
			</form>
		</div>
		<!--操作按钮  -->
		<xblock>
		<button class="layui-btn layui-btn-danger" onclick="delAll()">
			<i class="layui-icon"></i>批量删除
		</button>
		<a type="button" class="layui-btn" href="${pageContext.request.contextPath}/contracts/addWho">
			<i class="layui-icon"></i>添加
		</a>
		<span class="x-right" style="line-height: 40px">总共有${lg2:length(pageInfo.list)}条数据 
		</span> </xblock>
		<!-- 表格展示 -->
		<table class="layui-table x-admin">
			<thead>
				<tr>
					<th>
						<div class="layui-unselect header layui-form-checkbox"
							lay-skin="primary">
							<i class="layui-icon">&#xe605;</i>
						</div>
					</th>

					<th>员工名称</th>
					<th>合同编号</th>
					<th>合同名称</th>
					<th>签约时间</th>
					<th>生效时间</th>
					<th>到期时间</th>
					<th>职务</th>
					<th>试用期限</th>
					<th>试用薪资</th>
					<th>转正时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<lg:forEach items="${pageInfo.list}" var="m">
					<tr>
						<td><div class="layui-unselect layui-form-checkbox"
								lay-skin="primary" data-id='${m.contract_id}'>
								<i class="layui-icon">&#xe605;</i>
							</div></td>
						<td style="display: none">${m.contract_id}</td>
						<td>${m.staff.staff_name}</td>
						<td>${m.contract_code}</td>
						<td>${m.contract_name}</td>
						<td><fmt:formatDate value="${m.signing_time}" /></td>
						<td><fmt:formatDate value="${m.contract_start}" /></td>
						<td><fmt:formatDate value="${m.contract_end}" /></td>
						<td>${m.contract_post}</td>
						<td>${m.use_time}</td>
						<td>￥${m.use_money}</td>
						<td><fmt:formatDate value="${m.formal_time}" /></td>
						<td><a title="编辑"
							href="${pageContext.request.contextPath}/contracts/updateOne?cid=${m.contract_id}"><i
								class="layui-icon">&#xe642;</i> </a> 
							<a title="删除"
							href="${pageContext.request.contextPath}/contracts/deleteOne?cid=${m.contract_id}"><i
								class="layui-icon">&#xe640;</i></a>
							<a title="查看文件" href="${pageContext.request.contextPath}/contracts/contractImage?contractName=${m.contract_file}">
								<i class="layui-icon">&#xe621;</i></a>
						</td>
					</tr>
				</lg:forEach>
			</tbody>
		</table>
		<!-- 分页 -->
		<div class="page">
			<div>
				<a class="prev"
					href="${pageContext.request.contextPath}/contracts/list?startPage=${pageInfo.prePage}&PageSize=${pageInfo.pageSize}">&lt;&lt;</a>
				<a class="num"
					href="${pageContext.request.contextPath}/contracts/list?startPage=1&PageSize=${pageInfo.pageSize}">首页</a>
				<lg:forEach items="${pageInfo.navigatepageNums}" var="na">
					<lg:if test="${na==pageInfo.pageNum}">
						<span class="current"
							href="${pageContext.request.contextPath}/contracts/list?startPage=${na}&PageSize=${pageInfo.pageSize}" style="font-size=16px">${na}</span> 
					</lg:if>
					<lg:if test="${na!=pageInfo.pageNum}">
						<a class="num"
							href="${pageContext.request.contextPath}/contracts/list?startPage=${na}&PageSize=${pageInfo.pageSize}">${na}</a>
					</lg:if>
				</lg:forEach>
				<a class="num"
					href="${pageContext.request.contextPath}/contracts/list?startPage=${pageInfo.pages}&PageSize=${pageInfo.pageSize}">尾页</a>
				<a class="prev"
					href="${pageContext.request.contextPath}/contracts/list?startPage=${pageInfo.nextPage}&PageSize=${pageInfo.pageSize}">&gt;&gt;</a>

				<span><form action="${pageContext.request.contextPath}/contracts/list" method="post">
						每页展示数量<input type="text" name="PageSize"
							value="${pageInfo.pageSize}" style="width: 30px;text-align: center" /> 
							<input value="刷新" class="glyphicon glyphicon-refresh" type="submit">
					</form></span>
			</div>
		</div>

	</div>

	<script>
		/* 批量删除 */
		function delAll(argument) {
			layer.confirm('确认要删除吗？',
				function() {
					var ids = tableCheck.getData();
					$.ajax({
						url : "${pageContext.request.contextPath}/contracts/deleteMany",
						type : "post",
						data : {
							"ids" : ids.join(",")
						},
						error : function() {
						},
						success : function(data) {
							if (data) {
								layer.msg('删除任务成功', {
									icon : 1,
									zIndex : 66,
								});
								$(".layui-form-checked")
										.not('.header')
										.parents('tr')
										.remove();
							} else {
								layer.msg('删除失败');

							}

						}

					});					

			});

		}



	</script>




	<script type="text/javascript"
		src="${pageContext.request.contextPath}/static/js/jquery-1.12.3.min.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
</body>
</html>